/*
 *   AS IS License
 * ==Naive Coders==
 */
package org.naive.metawatch.converter.cap;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.ParseException;
import org.naive.metawatch.converter.parser.cap.CapParseContext;

/**
 *
 * @author gbu.000
 */
public class CapRawComponent extends CapComponent {

    public byte[] bytes;

    @Override
    protected void parseAutomaticFields(CapParseContext px) throws ParseException {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            while (!px.isAtBlockBoundary()) {
                bos.write(px.readByte());
            }
            bos.close();
            bytes = bos.toByteArray();
        } catch (IOException ex) {
            ParseException exx = new ParseException("", px.getOffset());
            exx.initCause(ex);
            throw exx;
        }
    }
}
